
import os, pygame,math
from pygame.locals import *

from Card import Card
                             
class CardImages:

    cardImages = []
    backImage = None

    def __init__(self):
    
        self.suits = ['s','c','d','h']
        self.ranks = ['a','2','3','4','5','6','7','8','9','t','j','q','k']

        for s in self.suits:
            for r in self.ranks:
                self.cardImages.append(pygame.image.load("./cards/%s%s.gif" %
                                                         (r,s)).convert())

        self.backImage = pygame.image.load("./cards/b.gif")

##    def getCard(self, suit, rank):
##        return self.cardImages[(suit * 13) + (rank)]

    def getCard(self, card):
        """Returns and image given a card"""
        s = self.suits.index(card.suit)
        r = self.ranks.index(card.rank)
        return self.cardImages[(s * 13) + r]

    def getCardNum(self, number):
        return self.cardImages[number]

    def getBack(self):
        return self.backImage
    

